const http = require('http');

const childProcess = require('child_process');

const hostName = '127.0.0.1'; //本机地址
const port = '8123'; //端口号

const server = http.createServer((request,response) => {
  response.statusCode = 200; //响应状态码
  response.setHeader('Content-Type','text/plain; charset=utf-8'); //设置响应头部
  response.write('你好');
  response.write('不不bu');
  response.write('duiduidui');
  response.end('ok')
})

server.listen(port,hostName,()=>{
  // 在命令行打印运行结果
  console.log(`Server running at http://${hostName}:${port}/`);
  // 使用默认浏览器打开地址
  childProcess.exec(`start http://${hostName}:${port}/`);
})